<?php

global $config;
$info = $config['database'];

$database = [
    'driver' => $info['adapter'],
    'host' => $info['host'],
    'database' => $info['dbname'],
    'username' => $info['username'],
    'password' => $info['password'],
    'charset' => $info['charset'],
    'collation' => 'utf8_unicode_ci',
    'prefix' => $info['prefix'],
];

use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

// 创建链接
$capsule->addConnection($database);

// 设置全局静态可访问DB
$capsule->setAsGlobal();

// 启动Eloquent
$capsule->bootEloquent();